﻿@model IEnumerable<Web.Areas.Admin.Models.News>

@{
    ViewBag.Title = "行业新闻";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

@section header{
<script language="javascript" type="text/javascript" src="@Url.Content("~/Scripts/My97DatePicker/WdatePicker.js")"></script>
}

<style type="text/css">
    .gridColCheck{width:10%;}
    </style>
    <script type="text/javascript">
        $(function () {
            $("input[type='radio']").each(function () {
                $(this).click(function () {
                    $("#btnEdit").attr("href", "/Admin/News/Edit/" + $(this).attr("value"));
                    $("#btnDel").attr("href", "/Admin/News/Del/" + $(this).attr("value"));
                });
            });
        });
        function cusval() {
            var slt = $("input[type='radio']:checked").val();
            if (!slt) {
                alert("请选择要操作的数据！");
                return false;
            } else {
                return true;
            }
        }
        function cusDel() {
            var slt = $("input[type='radio']:checked").val();
            if (!slt) {
                alert("请选择要操作的数据！");
                return false;
            } else {
                return confirm('你确定要删除么？');
            }
        }
    </script>
    <div class="nav">当前位置 :-> 行业新闻</div>
<div class="toolbar">
    @Html.ActionLink("添加","Add", "News", new { area="Admin"},null)
    @Html.ActionLink("编辑", "Edit", "News", new { area = "Admin" }, new { @id = "btnEdit", onclick = "return cusval()" })
    @Html.ActionLink("删除", "Del", "News", new { area = "Admin" }, new { @id = "btnDel", onclick = "return cusDel()" })
    @Html.ActionLink("刷新", "Index", "News", new { area = "Admin" }, null)
</div>
<div class="searchbar">
    @using (Html.BeginForm()) {
    @Html.Label("tbxSearchNewsID", "新闻编号：") @Html.TextBox("tbxSearchNewsID", "")
    @Html.Label("tbxSearchNewsTitle", "新闻标题：") @Html.TextBox("tbxSearchNewsTitle", "")
    @Html.Label("tbxSearchNewsAuthor", "新闻作者：") @Html.TextBox("tbxSearchNewsAuthor", "")<br />
    @Html.Label("tbxSearchNewsSource", "新闻来源：") @Html.TextBox("tbxSearchNewsSource", "")
    @Html.Label("tbxSearchNewsTypeName", "新闻类别：") @Html.TextBox("tbxSearchNewsTypeName", "")
    @Html.Label("tbxSearchIsTop", "首页显示：") @Html.TextBox("tbxSearchIsTop", "")<br />
    @Html.Label("tbxSearchNewsBeginDate", "日期介于：") @Html.TextBox("tbxSearchNewsBeginDate", "", new { @onfocus = @"WdatePicker({maxDate:'#F{$dp.$D(\'tbxSearchNewsEndDate\')||\'2020-10-01\'}',dateFmt:'yyyy-MM-dd HH:mm:ss'})" })
    <text>和</text>
    @Html.TextBox("tbxSearchNewsEndDate", "", new { @onfocus = @"WdatePicker({minDate:'#F{$dp.$D(\'tbxSearchNewsBeginDate\')}',maxDate:'2020-10-01',dateFmt:'yyyy-MM-dd HH:mm:ss'})" })  
    <input type="submit" value="搜索" />
    }
</div>
<hr />
@{var grid = new WebGrid(source: Model, defaultSort: "NewsID", rowsPerPage: 10);}

@grid.GetHtml(
tableStyle: "grid",
headerStyle: "head",
alternatingRowStyle: "alt",
htmlAttributes: new { width = "100%" },
columns: grid.Columns(
grid.Column(format: @<text><input type="radio" name="rdoNews" value="@item.NewsID" /></text>),
            grid.Column("NewsID", "编号"),
                grid.Column("NewsTitle", "新闻标题", format: @<text><span title="@item.NewsTitle">@Html.FormatStr((string)item.NewsTitle, 10)</span></text>),
                grid.Column("NewsAuthor", "新闻作者"),
                    grid.Column("NewsSource", "新闻来源"),
                        grid.Column("NewsTypeName", "新闻类别"),
                    grid.Column("NewsDate", "发布时间"),
                    grid.Column("IsTop","首页显示")
)
)

